/**
 * Author(s): xuming.Wong <xuming.Wong@gmail.com>
 */
#include "CharacterModelArchive.h"

#include "NativeFile.h"

namespace PQGame
{
	const std::string CharacterModelArchive::PATH="character/";

	CharacterModelArchive::CharacterModelArchive()
	{
	}

	CharacterModelArchive& CharacterModelArchive::getSingleton()
	{
		static CharacterModelArchive inst;
		return inst;
	}

	bool CharacterModelArchive::modelFileExist(std::string path)
	{
		//std::string fullPath=PATH+path;
		return PQEngine::NativeFile::isExist(path);
		
	}

	M2File* CharacterModelArchive::openM2File(std::string path)
	{
		//std::string fullPath=PATH+path;
		PQEngine::NativeFile* file=new PQEngine::NativeFile(path);
		M2File* f=0;
		if(file->ok()){
			f=new M2File(file);		
		}
		
		delete file;
		return f;
	}

	M2SkinFile* CharacterModelArchive::openM2SkinFile(std::string path)
	{
		//std::string fullPath=PATH+path;
		PQEngine::NativeFile* file=new PQEngine::NativeFile(path);
		M2SkinFile* f=0;
		if(file->ok()){
			f=new M2SkinFile(file);
			
		}
		delete file;
		return f;
	}

	M2AnimFile* CharacterModelArchive::openM2AnimFile(std::string path)
	{
		//std::string fullPath=PATH+path;
		PQEngine::NativeFile* file=new PQEngine::NativeFile(path);
		M2AnimFile* f=0;
		if(file->ok()){
			f=new M2AnimFile(file);
			
		}
		delete file;
		return f;
	}

}
